
var ctx = ctx;
$(function(){
    loadDiv('patientCancelTurnOutListDiv',ctx+'/nurse/wardCirculation/findWaitCancelPatientList');
    loadDiv('bedListDiv',ctx+'/nurse/wardCirculation/emptyBedList');
});

function showCancelTurnOutForm(patientId,patVisitId){
    $("#patientCancelTurnOutDiv").attr("class","col-lg-8");
    $("#cancelTurnOutForm").show('normal');
    hideShowTableTd("patientCancelTurnOutDiv", '3,4,5', '2');
    return loadDiv('cancelTurnOutForm',ctx+'/nurse/wardCirculation/findInfoByCancelParam?patientId='+patientId+'&patVisitId='+patVisitId);
}
function newBedForm(bedRecId,bedNo){
    $("#bedRecId").val(bedRecId);
    $("#bedNo").val(bedNo);
}

function closeCancelTurnOutForm(){
    $("#patientCancelTurnOutDiv").attr("class","col-lg-12");
    $("#patientCancelTurnOutDiv").show('normal');
    hideShowTableTd("patientCancelTurnOutDiv", '3,4,5', '1');
    $("#cancelTurnOutForm").attr("style","display: none");
}

function saveCancleTurnOutLoad(divId,formId,url,hrefUrl){
    var no = $("#bedNo").val();
    if(no!=null&&no!=''){
        if(flag){
            if ($('#' + formId).parsley().validate()) {
                flag=false;
                $("#"+formId+" input,#"+formId+" select").removeAttr("disabled");
                $.ajax({
                    type: "POST",
                    data:$("#"+formId).serialize(),
                    url: url,
                    dataType: "json",
                    success: function(data) {
                        if (data.code == "success") {
                            toastr.success(data.data);
                            parent.layer.closeAll(); //关闭当前弹层
                            // loadDiv(divId,hrefUrl);
                            parent.refesh();
                        }else {
                            flag=true;
                            toastr.error(data.data);
                        }
                    },
                    error: function(data) {
                        toastr.error('网络连接错误,请检查网络');
                        flag=true;
                    }
                });
            }

        }
        return false;
    }else{
        toastr.info("请选择要入住的新床位！");
        return false;
    }

}
